﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace August.UI
{
    public class ImageBase : WheelBase
    {
       public Image Image;
        public ImageBase()
            : this(null)
        {

        }

        public ImageBase(Image _bitmap)
        {
            PointFs = new PointF[2];
            Image = _bitmap;
        }

        public ImageBaseCollection Parent;

        internal override void OnWheelPaint(PaintEventArgs e)
        {
            
            ImageBase imageBase = this;
            PointF[] pointFs = new PointF[2];
            imageBase.PointFs.CopyTo(pointFs, 0);
            int x1 = 0;
            int y1 = 0;
            int x2 = imageBase.Image.Width;
            int y2 = imageBase.Image.Height;
            using (System.Drawing.Drawing2D.Matrix transform = new Matrix())
            {
                transform.Scale(Parent.Owner.ScaleX, Parent.Owner.ScaleY, System.Drawing.Drawing2D.MatrixOrder.Append);
                transform.Translate(Parent.Owner.OffsetX, Parent.Owner.OffsetY, System.Drawing.Drawing2D.MatrixOrder.Append);
                e.Graphics.Transform = transform;
            }
            e.Graphics.DrawImage(imageBase.Image, new PointF[] { new PointF(x1, y1), new PointF(x2, y1), new PointF(x1, y2) }, new RectangleF(0, 0, imageBase.Image.Width, imageBase.Image.Height), GraphicsUnit.Pixel);
            base.OnWheelPaint(e);
        }
    }
}
